<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2020/8/27
  Time: 23:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>教务管理系统</title>
    <!--引入样式-->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/1.3.4/themes/default/easyui.css" />
    <link href="${pageContext.request.contextPath}/css/icon.css" type="text/css" rel="stylesheet" />
    <link href="${pageContext.request.contextPath}/css/login.css" type="text/css" rel="stylesheet" />

    <!--导入jquery和easyui-->
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js" ></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.3.4/locale/easyui-lang-zh_CN.js"></script>

</head>

<body class="imgbody">
<h1 class="myTitle">教务管理系统</h1>
<div id="login" class="easyui-window" title="用户登录" style="padding: 35px; width: 400px; height: 270px;">
    <div style="text-align: center; padding: 5px;">
        <form action="${pageContext.request.contextPath}/user/loginForm" method="post" id="myForm">
            <div>
                <img src="${pageContext.request.contextPath}/images/user.png" widthe="20" height="20" style="position: relative; top: 5px;" />
                <!--用户登录输入框-->
                <label >用户名:&nbsp;</label>
                <input class="easyui-textbox" type="text" name="userName" placeholder="请输入用户名"></input>
            </div>
            <br />
            <div>
                <img src="${pageContext.request.contextPath}/images/pwd.png" widthe="20" height="20" style="position: relative; top: 5px;" />
                <!--密码登录输入框-->
                <label >密&nbsp;码:&nbsp;&nbsp;&nbsp; </label>
                <input class="easyui-textbox" name="userPwd" type="password" placeholder="请输入密码" ></input>
            </div>

            <br/>
            <span style="color: red">${info}</span>
            <!--登录按钮-->
            <a href="javascript:void(0)" class="easyui-linkbutton" icon="icon-ok" onclick="login()">登录</a> &nbsp;&nbsp;&nbsp;

        </form>
    </div>
</div>

<!--用户注册模态框-->

<div id="regist" class="easyui-window" title="用户注册" style="padding: 35px; width: 400px; height: 270px;">
    <div style="text-align: center; padding: 5px;">

            <div>
                <img src="${pageContext.request.contextPath}/images/user.png" widthe="20" height="20" style="position: relative; top: 5px;" />
                <!--用户登录输入框-->
                <label >用户名:&nbsp;</label>
                <input class="easyui-textbox" type="text" id="userName" placeholder="请输入用户名"></input>
            </div>
            <br />
            <div>
                <img src="${pageContext.request.contextPath}/images/pwd.png" widthe="20" height="20" style="position: relative; top: 5px;" />
                <!--密码登录输入框-->
                <label >密&nbsp;码:&nbsp;&nbsp;&nbsp; </label>
                <input class="easyui-textbox" id="userPwd" type="password" placeholder="请输入密码" ></input>
            </div>
            <br />
            <div>
                <img src="${pageContext.request.contextPath}/images/pwd.png" widthe="20" height="20" style="position: relative; top: 5px;" />
                <!--密码登录输入框-->
                <label >确认密码: </label>
                <input class="easyui-textbox" id="surePwd" type="password" placeholder="请输入确认密码" ></input>
            </div>
            <br/>
            <!--保存按钮-->
            <a href="javascript:void(0)" class="easyui-linkbutton" icon="icon-ok" onclick="save()">保存</a>

    </div>
</div>

<script type="text/javascript">
    /* 登录触发方法 */
    function login() {
        //js的submit提交,myForm
        document.getElementById("myForm").submit();
    }

    //登录窗口的设置
    $('#login').window({
        collapsible:false,//关闭折叠按钮
        maximizable:false,//关闭最大化按钮
        minimizable:false,//关闭最小化按钮
        closable:false
    });
    //注册窗口的设置
    $('#regist').window({
        collapsible:false,//关闭折叠按钮
        maximizable:false,//关闭最大化按钮
        minimizable:false,//关闭最小化按钮
        closable:false
    });
    $(function () {
        $("#regist").window("close");
    })

    /* 打开注册 模态框*/
    function register() {
        //关闭登录模态框
        $("#login").window("close");
        //打开注册模态框
        $("#regist").window("open");
    }

    //保存
    function save() {


        var userName=$("#userName").val();
        var userPwd=$("#userPwd").val();
        var surePwd=$("#surePwd").val();
        //判断用户注册密码和确认密码是否一致
        if(userPwd!=surePwd){
            alert("用户密码和确认密码不一致")
        }else {
            $.ajax({
                url:"${pageContext.request.contextPath}/user/regist",
                type:"get",
                data:{"sysName":userName,"sysPwd":userPwd},
                dataType:"json",
                success:function (data) {
                    alert(data.info);
                    //打开登录模态框
                    $("#login").window("open");
                    //关闭注册模态框
                    $("#regist").window("close");
                }
            })
        }
    }

</script>
</body>

</html>
